home *** CD-ROM | disk | FTP | other *** search
/ Hottest 6 / Hottest 6 (1996)(PDSoft)[!].iso / software / programming / c / sipp / include / shaders.h < prev    next >
Encoding:
C/C++ Source or Header  |  1978-11-24  |  5.0 KB  |  174 lines

  1. /**
  2.  ** sipp - SImple Polygon Processor
  3.  **
  4.  **  A general 3d graphic package
  5.  **
  6.  **  Copyright Equivalent Software HB  1992
  7.  **
  8.  ** This program is free software; you can redistribute it and/or modify
  9.  ** it under the terms of the GNU General Public License as published by
  10.  ** the Free Software Foundation; either version 1, or any later version.
  11.  ** This program is distributed in the hope that it will be useful,
  12.  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  ** GNU General Public License for more details.
  15.  ** You can receive a copy of the GNU General Public License from the
  16.  ** Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  **/
  18.  
  19. /**
  20.  ** shaders.h - This include file defines the different shaders availiable
  21.  **             in sipp. Each shader is defined by a structure containing 
  22.  **             the necessary parameters to describe how a surface should 
  23.  **             be shaded with that particular shader, and the extern 
  24.  **             declaration of the shader function itself.
  25.  **/
  26.  
  27.  
  28. #ifndef _SHADERS_H
  29. #define _SHADERS_H
  30.  
  31.  
  32. #include <sipp.h>
  33.  
  34.  
  35.  
  36. /*
  37.  * Surface description used in phong_shader().
  38.  */
  39. typedef struct {
  40.     double ambient;     /* Fraction of color visible in ambient light */
  41.     double diffuse;     /* Diffuse reflexion factor */
  42.     double specular;    /* Specular reflexion factor */
  43.     int    spec_exp;    /* Exponent in the specular calculation */
  44.     Color  color;       /* Color of the surface */
  45.     Color  opacity;     /* Opacity of the surface */
  46. } Phong_desc;
  47.  
  48.  
  49.  
  50. /*
  51.  * Surface description used in strauss_shader().
  52.  */
  53. typedef struct {
  54.     double ambient;       /* Fraction of color visible in ambient light */
  55.     double smoothness;    /* Smoothness of the surface [0, 1] */
  56.     double metalness;     /* Metalness of the surface [0, 1] */
  57.     Color  color;         /* Base color of the surface */
  58.     Color  opacity;       /* Opacity of the surface */
  59. } Strauss_desc;
  60.  
  61.  
  62.  
  63. /* 
  64.  * Surface description for the bozo shader.
  65.  */
  66. typedef struct {
  67.     Color   *colors;
  68.     int      no_of_cols;
  69.     double   ambient;
  70.     double   specular;
  71.     double   c3;
  72.     double   scale;        /* Scale the texture by this value */
  73.     Color    opacity;      /* Opacity of the surface */
  74. } Bozo_desc;
  75.     
  76.  
  77.  
  78. /*
  79.  * Surface description used by the wood shader. This shader
  80.  * creates a solid texture (using noise & turbulence) that
  81.  * simulates wood.
  82.  */
  83. typedef struct {
  84.     double   ambient;
  85.     double   specular;
  86.     double   c3;
  87.     double   scale;        /* Scale the wood texture by this value */
  88.     Color    base;         /* "Base" color of the surface */
  89.     Color    ring;         /* Color of the darker rings */
  90.     Color    opacity;      /* Opacity of the surface */
  91. } Wood_desc;
  92.  
  93.  
  94.  
  95. /*
  96.  * Surface description used by the marble shader. marble_shader
  97.  * creates a solid texture (using noise & turbulence) that
  98.  * simulates marble.
  99.  */
  100. typedef struct {
  101.     double   ambient;
  102.     double   specular;
  103.     double   c3;
  104.     double   scale;        /* Scale the marble texture by this value */
  105.     Color    base;         /* "Base" color of the surface */
  106.     Color    strip;        /* Color of the "stripes" in the marble */
  107.     Color    opacity;      /* Opacity of the surface */
  108. } Marble_desc;
  109.  
  110.  
  111.  
  112. /*
  113.  * Surface description used by the granite shader. granite_shader
  114.  * creates a solid texture (using noise) that mixes two colors
  115.  * to simulate granite.
  116.  */
  117. typedef struct {
  118.     double   ambient;
  119.     double   specular;
  120.     double   c3;
  121.     double   scale;        /* Scale the texture by this value */
  122.     Color    col1;         /* The two color components */
  123.     Color    col2;
  124.     Color    opacity;      /* Opacity of the surface */
  125. } Granite_desc;
  126.  
  127.  
  128.  
  129. /*
  130.  * Mask shader. It uses mask image (ususally a bitmap) to
  131.  * choose between two other shaders. When a
  132.  * surface is shaded it calls masker() to check the
  133.  * u, v coordinate in the mask and calls one of two other 
  134.  * shaders depending of the outcome of that test.
  135.  */
  136. typedef struct {
  137.     Shader *t_shader;           /* Shader to call if mask(x, y) != 0 */
  138.     void   *t_surface;          /* Surface description for fg_shader */
  139.     Shader *f_shader;           /* Shader to call if mask(x, y) == 0 */
  140.     void   *f_surface;          /* Surface description for bg_shader */
  141.     void   *mask_data;          /* Pointer to data for masking function */
  142.     bool  (*masker)();          /* Function that tests a pixel value */
  143. } Mask_desc;
  144.  
  145.  
  146. /*
  147.  * Surface description for the bumpy_shader(). This shader 
  148.  * fiddles with the surface normals of a surface so the surface 
  149.  * looks bumpy.
  150.  */
  151.  
  152. typedef struct {
  153.     Shader *shader;
  154.     void   *surface;
  155.     double scale;
  156.     bool   bumpflag;
  157.     bool   holeflag;
  158. } Bumpy_desc;
  159.  
  160.  
  161. /*
  162.  * Declarations of the actual shading functions.
  163.  */
  164. extern void strauss_shader();
  165. extern void marble_shader();
  166. extern void granite_shader();
  167. extern void bozo_shader();
  168. extern void mask_shader();
  169. extern void bumpy_shader();
  170. extern void planet_shader();
  171. extern void wood_shader();
  172.  
  173. #endif /* _SHADERS_H */
  174.